package model;

import java.util.ArrayList;
import java.util.List;

import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

import entidade.Cartao;

@SuppressWarnings({ "serial", "rawtypes" })
public class CartaoComboBoxModel extends AbstractListModel implements
		ComboBoxModel {
	private Object selectedItem;
	private List<Cartao> list;

	public CartaoComboBoxModel() {
		list = new ArrayList<Cartao>();
	}

	public CartaoComboBoxModel(List<Cartao> lista) {
		this();
		list.addAll(lista);
	}

	@Override
	public int getSize() {
		return list.size();
	}

	@Override
	public Cartao getElementAt(int index) {
		Cartao c = list.get(index);
		return c;
	}

	@Override
	public void setSelectedItem(Object anItem) {
		selectedItem = anItem;
	}

	@Override
	public Object getSelectedItem() {
		return selectedItem;
	}

}
